import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:
 * Date: 2024-09-18
 * Time: 16:58
 */
public class Test {
    public class BinaryTree {
        static class TreeNode {
            public char val;
            public TreeNode left;
            public TreeNode right;

            public TreeNode(char val) {
                this.val = val;
            }
        }

        public TreeNode createTree() {
            TreeNode A = new TreeNode('A');
            TreeNode B = new TreeNode('B');
            TreeNode C = new TreeNode('C');
            TreeNode D = new TreeNode('D');
            TreeNode E = new TreeNode('E');
            TreeNode F = new TreeNode('F');
            TreeNode G = new TreeNode('G');
            TreeNode H = new TreeNode('H');

            A.left = B;
            A.right = C;
            B.left = D;
            B.right = E;
            E.right = H;
            C.left = F;
            C.right = G;

            return A;
        }
        private boolean getPath(TreeNode root,
                                TreeNode node,
                                Stack<TreeNode> stack){
            if(root == null){
                return false;
            }
            stack.push(root);
            if (root == node) {
                return true;
            }
            boolean ret = getPath(root.left,node ,stack);
            if(ret){
                return true;
            }
            ret = getPath(root.right, node, stack);
            if(ret){
                return true;
            }
            stack.pop();
            return false;
        }
    }

}
